package com.nbsaas.boot.shopArticle.rest.convert;

import com.nbsaas.boot.shopArticle.data.entity.ShopArticle;
import com.nbsaas.boot.shopArticle.api.domain.response.ShopArticleResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 实体对象转化成响应对象
*/

public class ShopArticleResponseConvert  implements Converter<ShopArticleResponse,ShopArticle> {

    @Override
    public ShopArticleResponse convert(ShopArticle source) {
        ShopArticleResponse  result = new  ShopArticleResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getDocument()!=null){
                    result.setNote(source.getDocument().getNote());
                    }
                    if(source.getShop()!=null){
                        result.setShop(source.getShop().getId());
                    }
                    if(source.getCatalog()!=null){
                        result.setCatalog(source.getCatalog().getId());
                    }
                    if(source.getDocument()!=null){
                        result.setDocument(source.getDocument().getId());
                    }
                    if(source.getShop()!=null){
                        result.setShopName(source.getShop().getName());
                    }
                    if(source.getCatalog()!=null){
                        result.setCatalogName(source.getCatalog().getName());
                    }
                    if(source.getStoreState()!=null){
                        result.setStoreStateName(String.valueOf(source.getStoreState()));
                    }
        return result;
    }

}

